﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using TCDL.GLOBAL;
using TCDL.BUS;

namespace TCDL
{
    public partial class frmChiTietLLV : Form
    {
        gConnect[] gCon = new gConnect[1];
        XemDSBUS ds = new XemDSBUS();
        int iCount = 1;
        string strMNV;

        public frmChiTietLLV(gConnect[] gCon, String strMNV)
        {
            InitializeComponent();
            this.gCon = gCon;
            this.strMNV = strMNV;
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmChiTietLLV_Load(object sender, EventArgs e)
        {
            iCount = 1;
            gConnect[] gCon = new gConnect[iCount];
            gCon[0] = new gConnect("@MaNV", strMNV);
            dataGridView1.DataSource = new XemDSBUS().XemDS("Sp_XemLamViec", gCon, iCount);
        }

        private void btnHuyLich_Click(object sender, EventArgs e)
        {
            string strMaLL = dataGridView1.Rows[SelectedRowIndex].Cells["MaLL"].Value.ToString();
            int iMaLL = Int32.Parse(strMaLL);

            iCount = 2;
            gConnect[] gCon = new gConnect[iCount];
            gCon[0] = new gConnect("@MaNV", strMNV.Trim());
            gCon[1] = new gConnect("@MaLL", iMaLL);
            ds.ThemDS("Sp_HuyLamViec", gCon, iCount);
            frmChiTietLLV_Load(sender, e);
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
          
        }

        int SelectedRowIndex = -1;
        private void dataGridView1_SelectionChanged_1(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count > 0)
            {
                SelectedRowIndex = dataGridView1.SelectedCells[0].RowIndex;
            }
        }
    }
}
